﻿using 算法入门.Utils;

namespace 算法入门.ViewModels
{
    public class BitOperationViewModel:BindableBase
    {

        /// <summary>
        /// 绑定二进制的字符串结果
        /// </summary>
        private string bitResult;

        public string BitResult
        {
            get { return bitResult; }
            set { bitResult = value; RaisePropertyChanged(); }
        }


        /// <summary>
        /// 绑定界面上的整数输入框的值
        /// </summary>
        private int intValue;

        public int IntValue
        {
            get { return intValue; }
            set { intValue = value; RaisePropertyChanged(); }
        }


        public DelegateCommand PrintBitCommand { get; private set; }

        public BitOperationViewModel()
        {
            BitResult = "等待输出......";

            //初始化命令
            PrintBitCommand = new DelegateCommand(PrintCommandFunc);
        }

        /// <summary>
        /// 打印整数的二进制字符串
        /// </summary>
        /// <exception cref="NotImplementedException"></exception>
        private void PrintCommandFunc()
        {
            BitResult = BitOperatorHelp.GetBitStr(IntValue);
        }
    }
}
